package com.dk.common.dbaccess.entity;

import java.io.Serial;
import java.io.Serializable;

public abstract class AbstractEntity<ID extends Serializable> implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;


    public abstract ID getId();

    public abstract void setId(final ID id);

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        if (!getClass().equals(obj.getClass())) {
            return false;
        }
        AbstractEntity<?> that = (AbstractEntity<?>) obj;
        return this.getId() != null && this.getId().equals(that.getId());
    }

    @Override
    public int hashCode() {
        int hashCode = 17;
        hashCode += (getId() == null ? 0 : getId().hashCode()) * 31;
        return hashCode;
    }
}
